package ch.uzh.ifi.sonar.actions;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.swt.SWT;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;
import org.eclipse.ui.PlatformUI;

import ch.uzh.ifi.sonar.storage.IStorage;
import ch.uzh.ifi.sonar.storage.TeneoHibernateStorage;

public class InitializeDatabaseAction implements IWorkbenchWindowActionDelegate {


	@Override
	public void run(IAction action) {
		// TODO Auto-generated method stub
		IStorage storage = new TeneoHibernateStorage();		
		storage.createNewModelDB();
		if(! storage.isInitialized())
			storage.initDataStore();
		MessageDialog.open(MessageDialog.INFORMATION, 
				PlatformUI.getWorkbench().getDisplay().getActiveShell(), "Initialized ", "the new database schema is created and initliazed", SWT.None);
	}

	@Override
	public void selectionChanged(IAction action, ISelection selection) {
		// TODO Auto-generated method stub

	}

	@Override
	public void dispose() {
		// TODO Auto-generated method stub

	}

	@Override
	public void init(IWorkbenchWindow window) {
		// TODO Auto-generated method stub

	}

}
